package kr.hkit.myframework.uicomp;

import java.util.ArrayList;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.SwingConstants;

public class InputComboPanel extends JPanel {
	private JLabel lbl;
	private JComboBox cb;

	/**
	 * Create the panel.
	 */
	public InputComboPanel() {

		initialize();
	}

	public JComboBox getCb() {
		return cb;
	}


	public void setCb(int i) {
		this.cb.setSelectedIndex(i);
	}
	public void setCb(String s) {
		this.cb.setSelectedItem(s);
	}

	public InputComboPanel(String s, ArrayList<String> list) {
		
		initialize();
		addList(list);
		lbl.setText(s);
	}
	
	private void addList(ArrayList<String> list) {
		for (int i = 0; i < list.size(); i++){
			cb.addItem(list.get(i));
		}
	}

	private void initialize() {
		setLayout(new GridLayout(0, 2, 0, 0));
		
		lbl = new JLabel("New label");
		lbl.setHorizontalAlignment(SwingConstants.CENTER);
		add(lbl);
		
		cb = new JComboBox();
		cb.setAlignmentX(CENTER_ALIGNMENT);
		add(cb);
	}

}
